#include "vector_float.h"
#include <iostream>
#include <vector>
using namespace std;

vector_float::vector_float(void)
{
	create_vector(0);
}

vector_float::vector_float(int s)
{
	create_vector(s);
}

vector_float::~vector_float(void)
{
	delete_vector();
}

void vector_float::create_vector(int s)
{
	if(s == 0)
	{
		vptr = nullptr;
		size = 0;
	}
	else
	{
		vptr = new float[s];
		size = s;
	}
}

void vector_float::delete_vector()
{
	delete[] vptr;
	size = 0;
	vptr = nullptr;
}

void vector_float::set(float value, int index)
{
	if(index >= 0 && index < size)
	{
		vptr[index] = value;
	}
	else
	{
		cout << "ERROR, try a lower index!" << endl;
	}
}

void vector_float::read_from_keyboard()
{
	cout << "Input " << size << " float values:\n";
	for(int i=0; i < size; i++)
	{
		cin >> vptr[i];
	}

}

void vector_float::print()
{
	cout << "vector contains: [";
	for (int i=0; i < size; i++)
	{
		cout << vptr[i];
		if (i < (size - 1)) 
		{
			cout << ", ";
		}
	}
	cout << "]" << endl;
}